package com.yanchangapp.adapter._n_manage;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanchangapp.R;
import com.yanchangapp.model.bean.LookLinkWorkBean;

import java.util.List;

/**
 * Created by apple on 2019-10-14.
 * description:查看关联工作选择的adapter
 */
public class LookLinkWorkAdapter extends BaseQuickAdapter<LookLinkWorkBean, BaseViewHolder> {
    public LookLinkWorkAdapter(@Nullable List<LookLinkWorkBean> data) {
        super(R.layout.item_look_link_work, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, LookLinkWorkBean item) {
        CheckBox checkBox =  helper.getView(R.id.checkbox);
        ImageView ivPen = helper.getView(R.id.ivPen);
        helper.setText(R.id.tvItemName,item.getTitle());
        boolean isEnable;
        if (item.getChoose() == null){
            isEnable = true;
        }else {
            if (item.getChoose()){
                isEnable = false;
            }else {
                isEnable = true;
            }
        }
        if (isEnable){
            ivPen.setVisibility(View.VISIBLE);
            Integer predictTime = item.getPredictTime();
            String timeShow = "期限";
            if (predictTime != null){
                timeShow = predictTime+"天";
            }
            helper.setText(R.id.tvTime,timeShow);
            helper.addOnClickListener(R.id.llTime).addOnClickListener(R.id.checkbox);
            checkBox.setChecked(item.isSelected());
        }else {
            ivPen.setVisibility(View.GONE);
            helper.setText(R.id.tvTime,"已做计划");
        }
        // 设置是否可以操作....
        checkBox.setEnabled(isEnable);
    }
}
